<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>图书管理系统 - 安装</title>
<style>
body{
    color:#444;
    font-size:12px;
    font-family:Arial;
    background:#F0F5F8;
}
a{
    text-decoration:none;
    color:#005EAC;
}
#main{
    width:760px;
    margin:10px auto;
    background:#fff;
    border:1px solid #eee;
    padding:15px;
}
h1{
    padding-bottom:10px;
    font-size:18px;
    border-bottom:1px solid #ddd;
}

ul.info{
    list-style:circle;
}
ul.info li{
    line-height:2;
}
ul.check {
    margin:10px 70px 0 10px;
    line-height:2;
}
ul.check li span{
    float:right;
}
.green{
    color:green;
}
.red{
    color:red;
}
.blue{
    color:#005EAC;
}
.orange{
    color:#ff9900;
}
input.btn{
    background-color:#005EAC;
    border-color:#B8D4E8 #124680 #124680 #B8D4E8;
    border-style:solid;
    border-width:1px;
    color:#FFFFFF;
    cursor:pointer;
    font-size:12px;
    height:23px;
    text-align:center;
}
table.setting{
    margin-left:40px;
}
table.setting th{
    width:150px;
    text-align:left;
}
</style>
<script>
function checkSubmit(o){
    if(o.dbadapter.value == 'mysql' || o.dbadapter.value == 'mysqli'){
        if(o.dbhost.value == ''){
            alert('数据库主机不能为空！');
            return false;
        }
    
        if(o.dbport.value == ''){
            alert('端口号不能为空！');
            return false;
        }
        if(o.dbhost.value == ''){
            alert('数据库主机不能为空！');
            return false;
        }
        if(o.dbuser.value == ''){
            alert('数据库用户名不能为空！');
            return false;
        }
        if(o.dbname.value == ''){
            alert('数据库名不能为空！');
            return false;
        }
    }else if(o.dbadapter.value == 'sqlite'){
        if(o.sqlitedbname.value == ''){
            alert('Sqlite数据库路径不能为空！');
            return false;
        }
    }else{
        alert('请选择数据库类型！');
        return false;
    }
    
    if(o.username.value == ''){
        alert('管理员用户名不能为空！');
        return false;
    }
    if(o.userpass.value == ''){
        alert('管理员密码不能为空！');
        return false;
    }
    
    if(o.passagain.value != o.userpass.value){
        alert('两次密码不一致！');
        return false;
    }
    
    if(o.url.value == ''){
        alert('站点URL不能为空!');
        return false;
    }
    o.submit();
}

function selected_adapter(val){
    if(val == 'sqlite'){
        document.getElementById('sqlite_div').style.display = '';
        document.getElementById('mysql_div').style.display = 'none';
        document.getElementById('dbauth_div').style.display = 'none';
        document.getElementById('pre_div').style.display = '';
    }else{
        document.getElementById('sqlite_div').style.display = 'none';
        document.getElementById('mysql_div').style.display = '';
        document.getElementById('dbauth_div').style.display = '';
        document.getElementById('pre_div').style.display = '';
    }
}
</script>
</head>
<body>
<div id="main">
<h1 class="blue">欢迎使图书管理系统！ <span class="orange">安装第一步：检查环境</span></h1>
<h2>系统环境</h2>

<ul class="check">
<?php
foreach(get_system_info() as $v)
{
	echo "<li><span>".$v[1]."</span>".$v[0]."</li>\n";
}
?>
</ul>
<h2>检测目录权限</h2>

<ul class="check">
<?php
if(is_dir(ROOTDIR.'conf') && is_writable(ROOTDIR.'conf'))
{
	echo "<li><span class=\"green\">可写</span> conf</li>\n";
}
else
{
	$dir_error = true;
	echo "<li><span class=\"red\">不可写</span> conf</li>\n";
}

if(is_dir(ROOTDIR.'data') && is_writable(ROOTDIR.'data'))
{
	echo "<li><span class=\"green\">可写</span> data</li>\n";
}
else
{
	$dir_error = true;
	echo "<li><span class=\"red\">不可写</span> data</li>\n";
}
?>
</ul>
<?php
if(!get_gd_version() || $dir_error)
{
	echo "<div align=\"center\" class=\"red\">检查到您的配置有问题，无法进行下一步安装</div>";
}
else
{
	echo "<div align=\"center\"><input type=\"button\" onclick=\"window.location.href='index.php?step=2'\" value=\"下一步\" class=\"btn\" /></div>";
}
?>
</div>
</body>
</html>